# class Integer (object):
#     def func (self, args):
#         # n sqrt(3) a ^ 2 / 4
#         n = len (args)
#         m = (3 ** 0.5) * (n ** 2) / 4
#         volume = m * min (args)
#         print (int (volume) + 6)
#
#
# if __name__ == '__main__':
#     a_list = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1]
#     interger = Integer ()
#     interger.func (a_list)

class Solution:
    def trap(self, height):
        """
        :type height: List[int]
        :rtype: int
        """
        res, hei_len = 0, len(height)
        for i in range(1, hei_len - 1):
            max_left, max_right = 0, 0
            for l in range(i + 1):
                max_left = max(max_left, height[l])
            for r in range(i, hei_len):
                max_right = max(max_right, height[r])
            res += min(max_left, max_right) - height[i]
        return res

if __name__ == '__main__':
    a_list = [0,1,0,2,1,0,1,3,2,1,2,1]
    interger = Solution()
    print(interger.trap(a_list))